// Eric Battalio
// http://blogs.msdn.com/ebattalio
// BizTalk Server 2006
// 
// Modified by Ignacio Quijas 
// Action: Recompiled for BizTalk 2010 Compatibility
// Last Modification Date: February 2011
//
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using Microsoft.BizTalk.BaseFunctoids;

namespace BizTalk.MapperExtensions.DBFunktoids
{
    class StoredProcedureRunner : BaseFunctoid
    {
        public StoredProcedureRunner()
            : base()
        {
            // Functoid ID must be > 6000
            ID = int.Parse(DBFunktoids.IDS_SPRUNNER_ID);

            // Resource assembly for functoid
            SetupResourceAssembly("BizTalk.MapperExtensions.DBFunktoids.DBFunktoids", Assembly.GetExecutingAssembly());

            // Configure text and toolbox pic
            SetName("IDS_SPRUNNER_NAME");
            SetTooltip("IDS_SPRUNNER_TOOLTIP");
            SetDescription("IDS_SPRUNNER_DESCRIPTION");
            SetBitmap("IDB_SPRUNNER_BITMAP");

            // Two parameters are required:
            //
            //  1: Database connection string
            //  2: Stored procedure name
            //
            // If the stored procedure has arguments (novel concept),
            // then _at least_ two more parameters are required:
            //
            //  3: Stored procedure parameter names
            //  4: Parameter one value
            // 
            // Note that you have to supply at least one parameter value
            // if you supply a parameter name; this could be changed or
            // you could write a parameterless proc wrapper.
            SetMinParams(2);
            HasVariableInputs = true;
            // This causes the mapper to emit code slightly differently
            HasSideEffects = true;

            // DBFunk.RunStoredProcedure
            SetExternalFunctionName(GetType().Assembly.FullName, "BizTalk.MapperExtensions.DBFunktoids.DBFunk", "RunStoredProcedure");

            // Category, output connection types
            Category = FunctoidCategory.DatabaseLookup;
            OutputConnectionType = ConnectionType.All;

            AddInputConnectionType(ConnectionType.AllExceptRecord);
            AddInputConnectionType(ConnectionType.AllExceptRecord);
        }
    }
}
